


# utworzenie drzewa
#trainVector <- load.loadFromFile('data/spambase.data.txt')
test.df <-read.csv('data/spambase2.data.txt')#, head=TRUE, sep = ",", dec=".")
#train<- as.matrix(trainVector)
ecoli.df = read.csv('data/ecoli.txt')
#head(train) <- c("V1","V2","V3","V4","V5","V6","V7","V8","V9","V10","V11","V12","V13","V14","V15","V16","V17","V18","V19","V20","V21","V22","V23","V24","V25","V26","V27","V28","V29","V30","V31","V32","V33","V34","V35","V36","V37","V38","V39","V40","V41","V42","V43","V44","V45","V46","V47","V48","V49","V50","V51","V52","V53","V54","V55","V56","V57","isSpam")

#test <- data.frame(train)
#testMatrix <- data.frame(trainMatrix[1713:1914,])

require(rpart)

test.tree1 = rpart(class ~ V1 + V2 + V3 + V4 + V5 + V6 + V7 + V8 + V9 + V10 + V11 + V12 + V13 + V14 + V15 + V16 + V17 + V18 + V19 + V20 + V21 + V22 + V23 + V24 + V25 + V26 + V27 + V28 + V29 + V30 + V31 + V32 + V33 + V34 + V35 + V36 + V37 + V38 + V39 + V40 + V41 + V42 + V43 + V44 + V45 + V46 + V47 + V48 + V49 + V50 + V51 + V52 + V53 + V54 + V55 + V56 + V57,method="class", data = test.df)
summary(test.tree1)

pred <-predict(test.tree1, newdata = test.df, type = "class")
mc <- table(test.df$class,pred)

ecoli.tree1 = rpart(class ~ mcv + gvh + lip + chg + aac + alm1 + alm2, method="class", data = ecoli.df)
summary(ecoli.tree1)

err.resub <- 1.0 - (mc[1,1]+mc[2,2])/sum(mc)
print(err.resub)

#testMatrix[0] <- [v1,v2,]
#fit <- rpart(v1 ~ v2+v2+v2,method="class", data=trainVector)	
#printcp(fit) # display the results 
